#include "Rectemper_server.h"

static int callback(void *data, int argc, char **argv, char **azColName)
{
    int i;
    for(i=0; i<argc; i++)
    {
        printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
    }
    printf("\n");
    return 0;
}


void Insert_to_sqlite(sqlite3 *db,char *sn, char *time, char *temper)
{
    char            *zErrMsg = NULL ;
    int             rv ;
    char            sql[128] ;
    snprintf(sql, sizeof(sql),  "INSERT INTO temperature (SN,TIME,TEMPER) VALUES ('%s','%s','%s');", sn, time, temper);
    rv = sqlite3_exec(db, sql, callback, 0, &zErrMsg ) ;
    if(rv != SQLITE_OK)
    {
        printf("Sqlite3 insert error: %s\n", zErrMsg) ;
        sqlite3_free(zErrMsg) ;
    }
    printf("After Insert!\n") ;
}

